
#pragma once

#include <ttg/services.h>

#include "Common.h"

//Calculates n-th fibonacci number serially.
//Returns n-th number and elapsed time (in seconds).
template <class WorkType>
std::pair<WorkType, double> serialFibonacci(size_t n)
{
	//Initing.
	Matrix2x2<WorkType> multiplier(1, 1, 1, 0);
	Matrix2x2<WorkType> cur = multiplier;
	//Calulating.
	double t_start = ttg::services::Timer::getRef()->getSeconds();
	for (size_t i = 1; i < n; i++)
		cur = cur * multiplier;
	double t_end = ttg::services::Timer::getRef()->getSeconds();
	//Returning result.
	return std::make_pair(cur(0, 0), t_end -t_start);
}
